package com.example.erat.dto;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 统一响应结果
 */
@Data
@NoArgsConstructor
public class ResponseResult<T> {

    /**
     * 响应码
     */
    private String code;
    
    /**
     * 响应消息
     */
    private String message;
    
    /**
     * 响应数据
     */
    private T data;
    
    /**
     * 成功
     */
    public static <T> ResponseResult<T> success() {
        return success(null);
    }
    
    /**
     * 成功
     */
    public static <T> ResponseResult<T> success(T data) {
        ResponseResult<T> result = new ResponseResult<>();
        result.setCode("200");
        result.setMessage("操作成功");
        result.setData(data);
        return result;
    }
    
    /**
     * 失败
     */
    public static <T> ResponseResult<T> error(String code, String message) {
        ResponseResult<T> result = new ResponseResult<>();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
    
    /**
     * 失败
     */
    public static <T> ResponseResult<T> error(String message) {
        return error("500", message);
    }
} 